package com.cainaer.orders.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cainaer.orders.domain.OrderOperateHistory;
import com.cainaer.orders.mapper.OrderOperateHistoryMapper;
import com.cainaer.orders.service.IOrderOperateHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单操作记录表 服务实现类
 * </p>
 *
 * @author Tina
 * @since 2020-09-11
 */
@Service
public class OrderOperateHistoryServiceImpl extends ServiceImpl<OrderOperateHistoryMapper, OrderOperateHistory> implements IOrderOperateHistoryService {

    @Autowired
    private OrderOperateHistoryMapper orderOperateHistoryMapper;

    /**
     * 新增订单操作记录
     *
     * @param orderOperateHistory
     * @return
     */
    @Override
    public Integer insertOrderOperate(OrderOperateHistory orderOperateHistory) {
        return orderOperateHistoryMapper.insert(orderOperateHistory);
    }

    /**
     * 编辑订单操作记录
     *
     * @param orderOperateHistory
     * @return
     */
    @Override
    public Integer editOrderOperate(OrderOperateHistory orderOperateHistory) {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("order_id", orderOperateHistory.getOrderId());
        return orderOperateHistoryMapper.update(orderOperateHistory, updateWrapper);
    }

    /**
     * 查询订单操作记录
     *
     * @param orderOperateHistory
     * @return
     */
    @Override
    public List<OrderOperateHistory> selectOrderOperateHistory(OrderOperateHistory orderOperateHistory) {
        QueryWrapper queryWrapper = new QueryWrapper();
        return orderOperateHistoryMapper.selectList(queryWrapper);
    }
}
